package cn.liutao.common.servlet;

import cn.liutao.websocket.SocketServer;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.ServletConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;


/**
 * @author liutao
 * @Description 初始化mybatisFlex
 * @date 2023/10/31 12:26
 * @Version 1.0
 */
@WebServlet(loadOnStartup = 1,name = "websocketServlet",value = "/websocket")
@Slf4j
public class WebSocketServlet extends HttpServlet {
    private SocketServer socketServer;
    @Override
    public void init(ServletConfig config){
        socketServer = SocketServer.getInstance();
        socketServer.start();
        log.info("web");
    }



    @Override
    public void destroy() {
        try {
            log.info("websocket服务停止");
            socketServer.stop();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
